chore: make settings keys const static member of ConfigFile class.
authorCamila Ayres <hello@camilasan.com>
Tue, 15 Apr 2025 10:51:42 +0000 (12:51 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 15 Apr 2025 20:47:11 +0000 (20:47 +0000)
Signed-off-by: Camila Ayres <hello@camilasan.com>
src/gui/accountmanager.cpp
src/libsync/configfile.cpp
src/libsync/configfile.h

index a224d49647a79e0aeadadede09414a067a1ef900..a10a02cd81f05656538728b2e3be18437925438b 100644 (file)
@@ -84,13 +84,6 @@ constexpr auto maxAccountVersion = 13;
 constexpr auto serverHasValidSubscriptionC = "serverHasValidSubscription";
 
 constexpr auto generalC = "General";
-constexpr auto isVfsEnabledC = "isVfsEnabled";
-constexpr auto launchOnSystemStartupC = "launchOnSystemStartup";
-constexpr auto optionalServerNotificationsC = "optionalServerNotifications";
-constexpr auto promptDeleteC = "promptDeleteAllFiles";
-constexpr auto showCallNotificationsC = "showCallNotifications";
-constexpr auto showChatNotificationsC = "showChatNotifications";
-constexpr auto showInExplorerNavigationPaneC = "showInExplorerNavigationPane";
 }
 
 
@@ -261,13 +254,13 @@ bool AccountManager::restoreFromLegacySettings()
     }
 
     ConfigFile configFile;
-    configFile.setVfsEnabled(settings->value(QLatin1String(isVfsEnabledC)).toBool());
-    configFile.setLaunchOnSystemStartup(settings->value(QLatin1String(launchOnSystemStartupC)).toBool());
-    configFile.setOptionalServerNotifications(settings->value(QLatin1String(optionalServerNotificationsC)).toBool());
-    configFile.setPromptDeleteFiles(settings->value(QLatin1String(promptDeleteC)).toBool());
-    configFile.setShowCallNotifications(settings->value(QLatin1String(showCallNotificationsC)).toBool());
-    configFile.setShowChatNotifications(settings->value(QLatin1String(showChatNotificationsC)).toBool());
-    configFile.setShowInExplorerNavigationPane(settings->value(QLatin1String(showInExplorerNavigationPaneC)).toBool());
+    configFile.setVfsEnabled(settings->value(configFile.isVfsEnabledC).toBool());
+    configFile.setLaunchOnSystemStartup(settings->value(configFile.launchOnSystemStartupC).toBool());
+    configFile.setOptionalServerNotifications(settings->value(configFile.optionalServerNotificationsC).toBool());
+    configFile.setPromptDeleteFiles(settings->value(configFile.promptDeleteC).toBool());
+    configFile.setShowCallNotifications(settings->value(configFile.showCallNotificationsC).toBool());
+    configFile.setShowChatNotifications(settings->value(configFile.showChatNotificationsC).toBool());
+    configFile.setShowInExplorerNavigationPane(settings->value(configFile.showInExplorerNavigationPaneC).toBool());
     ClientProxy().saveProxyConfigurationFromSettings(*settings);
 
     // Try to load the single account.
index 8f875cc4d0f887265d31c8c153c993ed95e4a4ed..d3d0f5cb0516799a3cb28441f917a7b25a33d547 100644 (file)
@@ -53,13 +53,8 @@ static constexpr char forceSyncIntervalC[] = "forceSyncInterval";
 static constexpr char fullLocalDiscoveryIntervalC[] = "fullLocalDiscoveryInterval";
 static constexpr char notificationRefreshIntervalC[] = "notificationRefreshInterval";
 static constexpr char monoIconsC[] = "monoIcons";
-static constexpr char promptDeleteC[] = "promptDeleteAllFiles";
 static constexpr char deleteFilesThresholdC[] = "deleteFilesThreshold";
 static constexpr char crashReporterC[] = "crashReporter";
-static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications";
-static constexpr char showCallNotificationsC[] = "showCallNotifications";
-static constexpr char showChatNotificationsC[] = "showChatNotifications";
-static constexpr char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";
 static constexpr char skipUpdateCheckC[] = "skipUpdateCheck";
 static constexpr char autoUpdateCheckC[] = "autoUpdateCheck";
 static constexpr char updateCheckIntervalC[] = "updateCheckInterval";
@@ -67,7 +62,6 @@ static constexpr char updateSegmentC[] = "updateSegment";
 static constexpr char updateChannelC[] = "updateChannel";
 static constexpr char overrideServerUrlC[] = "overrideServerUrl";
 static constexpr char overrideLocalDirC[] = "overrideLocalDir";
-static constexpr char isVfsEnabledC[] = "isVfsEnabled";
 static constexpr char geometryC[] = "geometry";
 static constexpr char timeoutC[] = "timeout";
 static constexpr char chunkSizeC[] = "chunkSize";
@@ -81,7 +75,6 @@ static constexpr char logExpireC[] = "logExpire";
 static constexpr char logFlushC[] = "logFlush";
 static constexpr char showExperimentalOptionsC[] = "showExperimentalOptions";
 static constexpr char clientVersionC[] = "clientVersion";
-static constexpr char launchOnSystemStartupC[] = "launchOnSystemStartup";
 
 static constexpr char proxyHostC[] = "Proxy/host";
 static constexpr char proxyTypeC[] = "Proxy/type";
@@ -206,32 +199,32 @@ bool ConfigFile::setConfDir(const QString &value)
 bool ConfigFile::optionalServerNotifications() const
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(optionalServerNotificationsC), true).toBool();
+    return settings.value(optionalServerNotificationsC, true).toBool();
 }
 
 bool ConfigFile::showChatNotifications() const
 {
     const QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(showChatNotificationsC), true).toBool() && optionalServerNotifications();
+    return settings.value(showChatNotificationsC, true).toBool() && optionalServerNotifications();
 }
 
 void ConfigFile::setShowChatNotifications(const bool show)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(showChatNotificationsC), show);
+    settings.setValue(showChatNotificationsC, show);
     settings.sync();
 }
 
 bool ConfigFile::showCallNotifications() const
 {
     const QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(showCallNotificationsC), true).toBool() && optionalServerNotifications();
+    return settings.value(showCallNotificationsC, true).toBool() && optionalServerNotifications();
 }
 
 void ConfigFile::setShowCallNotifications(bool show)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(showCallNotificationsC), show);
+    settings.setValue(showCallNotificationsC, show);
     settings.sync();
 }
 
@@ -245,13 +238,13 @@ bool ConfigFile::showInExplorerNavigationPane() const
 #endif
         ;
     QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(showInExplorerNavigationPaneC), defaultValue).toBool();
+    return settings.value(showInExplorerNavigationPaneC, defaultValue).toBool();
 }
 
 void ConfigFile::setShowInExplorerNavigationPane(bool show)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(showInExplorerNavigationPaneC), show);
+    settings.setValue(showInExplorerNavigationPaneC, show);
     settings.sync();
 }
 
@@ -288,7 +281,7 @@ chrono::milliseconds ConfigFile::targetChunkUploadDuration() const
 void ConfigFile::setOptionalServerNotifications(bool show)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(optionalServerNotificationsC), show);
+    settings.setValue(optionalServerNotificationsC, show);
     settings.sync();
 }
 
@@ -1062,13 +1055,13 @@ bool ConfigFile::showMainDialogAsNormalWindow() const {
 bool ConfigFile::promptDeleteFiles() const
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(promptDeleteC), false).toBool();
+    return settings.value(promptDeleteC, false).toBool();
 }
 
 void ConfigFile::setPromptDeleteFiles(bool promptDeleteFiles)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(promptDeleteC), promptDeleteFiles);
+    settings.setValue(promptDeleteC, promptDeleteFiles);
 }
 
 int ConfigFile::deleteFilesThreshold() const
@@ -1219,13 +1212,13 @@ void ConfigFile::setClientVersionString(const QString &version)
 bool ConfigFile::launchOnSystemStartup() const
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    return settings.value(QLatin1String(launchOnSystemStartupC), true).toBool();
+    return settings.value(launchOnSystemStartupC, true).toBool();
 }
 
 void ConfigFile::setLaunchOnSystemStartup(const bool autostart)
 {
     QSettings settings(configFile(), QSettings::IniFormat);
-    settings.setValue(QLatin1String(launchOnSystemStartupC), autostart);
+    settings.setValue(launchOnSystemStartupC, autostart);
 }
 
 bool ConfigFile::serverHasValidSubscription() const
index f38fba1f11ab047d1d9166a2b8081ed1feab0088..fdac40e721642610b8232412c088f1bd68eed769 100644 (file)
@@ -252,6 +252,14 @@ public:
     [[nodiscard]] static QString discoveredLegacyConfigPath();
     static void setDiscoveredLegacyConfigPath(const QString &discoveredLegacyConfigPath);
 
+    static constexpr char isVfsEnabledC[] = "isVfsEnabled";
+    static constexpr char launchOnSystemStartupC[] = "launchOnSystemStartup";
+    static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications";
+    static constexpr char promptDeleteC[] = "promptDeleteAllFiles";
+    static constexpr char showCallNotificationsC[] = "showCallNotifications";
+    static constexpr char showChatNotificationsC[] = "showChatNotifications";
+    static constexpr char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";
+
 protected:
     [[nodiscard]] QVariant getPolicySetting(const QString &policy, const QVariant &defaultValue = QVariant()) const;
     void storeData(const QString &group, const QString &key, const QVariant &value);